package demo;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class demo8 {
    public static void main(String[] args) {
        ThreadPoolExecutor pool=new ThreadPoolExecutor(
                5,
                10,
                3,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(100),//任务队列
                new ThreadPoolExecutor.DiscardPolicy()//拒绝策略为忽略最新任务
        );
        for (int i = 0; i < 2000; i++) {
            pool.execute(()->{
                System.out.println(Thread.currentThread().getName()+"已执行");
            });
        }
    }


}
